package com.fengke.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Locale;

import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

public class PropertiesUtil {
	private static ApplicationContext ctx = ContextManager.getContext();

	private static ReloadableResourceBundleMessageSource r = (ReloadableResourceBundleMessageSource) ctx
			.getBean("resourceConfigurer");
	
	public static String getResourceString(String key) {
		return r.getMessage(key, null, new Locale(""));
	}
	
	public static void copyProp(Object dest, Object orig) throws Exception {
		try {
			PropertyUtils.copyProperties(dest, orig);
		} catch (IllegalAccessException e) {
			throw new Exception("13707 , 对象复制异常1", e);
		} catch (InvocationTargetException e) {
			throw new Exception("13707, 对象复制异常2", e);
		} catch (NoSuchMethodException e) {
			throw new Exception("13707, 对象复制异常3", e);
		}
	}

}
